/**
 *Description:
 *Version:1.0.0
 *@author shihb
 *@date 2022/9/15 23:21
 */
public class demo {

  public static void main(String[] args) {
    A a=new A();
    A ab=new B();
    B b=new B();
    C c=new C();
    D d = new D();
    System.out.println(a.show(b)); //aa 简单
    System.out.println(a.show(c)); // aa 简单
    System.out.println(a.show(d)); // ad 简单
    System.out.println(ab.show(b)); //ba 易错
    System.out.println(ab.show(c));//ba
    System.out.println(ab.show(d));// ad
    System.out.println(b.show(b)); //bb
    System.out.println(b.show(c)); //bb
    System.out.println(b.show(d));// ad 易错

    System.out.println(a.show(b)); //aa 简单
    System.out.println(ab.show(b)); //ba 易错
    System.out.println(ab.show(d));// ad
  }
}

class A {
  public  String show(A obj){
    return "A and A";
  }
  public  String show(D obj){
    return "A and D";
  }
}
class B extends A {
  public  String show(A obj){
    return "B and A";
  }
  public  String show(B obj){
    return "B and B";
  }
}
class C extends B{}
class D extends B{}
